<?php
	
	/**
	 * Assign variables into smarty {$env.__VAR__} from devmods for titles and other stuff
	 * 
	 * 17/01/2011 - class creation
	 * 
	 * @author bsuter
	 * @package devmod
	 */
	class Devmod_method_assign extends Devmod_methods_abstraction {

		protected $after_operation = array(array(
										'for_method' => 'export', // in this method we want sth to handle | $devmod->>>EXPORT<<();
										'for_method_type' => 'frontend_list', // choose the type in this method | $devmod->type('>>LIST<<')->export();
										'use' => 'eval_assignement' // choose the local (in this class) method which will be executed
									));
		
		/**
		 * @param $args [array] array('__IDENTIFIER__' => '__VALUE__', 'title' => '%%title%%);
		 */
		public function set_config($args)
		{
			$this->update_config('assign', $args[0]);
		}

		public function eval_assignement($args)
		{
			if(!isset($this->config[$this->type]['assign'])) return $args;
			
			if(count($args) !== 1)
			{
				new Yomm_Error("DevMod assign should be casted first by singleReturn(). count() of args is not equal 1.");
			}
			
			$check_item_block = $args[0];
			
			foreach($this->config[$this->type]['assign'] as $asg_name => $asg_value)
			{
				$this->register_var($asg_name, $this->helper->eval_vars($asg_value, $check_item_block));
			}
			
			return $args;
		}
	}
